import React from "react";
import { type RouteObject, createBrowserRouter } from 'react-router-dom'
import AuthRouter from "../router/authRouter";
import LayoutIndex from "../layout";

const Home = React.lazy(() => import("@/pages/home"));
const No404 = React.lazy(() => import("@/pages/404"));
const Order = React.lazy(() => import("@/pages/order"));
const Reload = React.lazy(() => import("@/pages/reload"));
const Login = React.lazy(() => import("@/pages/login"));

export const routes: RouteObject[] = [
  {
    id: "root",
    element: <AuthRouter />,
    children: [
      {
        path: "/login",
        element: <Login />,
        meta: {
          isWhite: true,
        }
      },
      {
        id: 'layout',
        element: <LayoutIndex />,
        children: [
          {
            path: '/',
            element: <Home />,
            meta: {
              title: '首页',
              icon: "HomeOutlined",
            },
          },
          {
            // path: "/order",
            // element: <Order />,
            meta: {
              icon: "CalendarOutlined",
              title: "订单",
            },
            children: [
              {
                path: "/order/list",
                element: <Order />,
                meta: {
                  icon: "CalendarOutlined",
                  title: "订单列表",
                  activeMenu: '/order/list',
                }
              },
            ],
          },
          // ...privateRoutes,
          {
            path: '/reload',
            element: <Reload />,
          },
        ],
      },
      {
        path: "*",
        element: <No404 />,
      },
    ],
  },
];

const router = createBrowserRouter(routes);

export default router;
